package BeenChina.PM.Service.Impl; 

import java.util.List; 
import BeenChina.PM.DAO.SystemInfoDao; 
import BeenChina.PM.Model.ModelRole;
import BeenChina.PM.Model.ModelUser;
import BeenChina.PM.Model.ModelUserRole;
import BeenChina.PM.Service.SystemInfoService;

public class SystemInfoServiceImpl implements SystemInfoService {
	
		private SystemInfoDao dao;

	    public SystemInfoDao getDao() {
	        return dao;
	    }

	    public void setDao(SystemInfoDao dao) {
	        this.dao = dao;
	    }
	    
	    @Override
	    public List<ModelUser> selectUsers(){   
			
	    	try{ 
				return this.dao.selectUsers();
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return null;
	         }  
	    }
	    
	    @Override
	    public Integer insertUser(ModelUser model)
	    {
	    	try{ 
	    		return this.dao.insertUser(model);
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return null;
	         }  
	    }
	    
	    @Override
	    public Integer updateUser(ModelUser model)
	    {
	    	try{
	    		return this.dao.updateUser( model );
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return null;
	         }  
	    }
	    
	    @Override	    
	    public Integer deleteUser(String userid)
	    {
	    	try{
				return this.dao.deleteUser(userid);
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return null;
	         }  
	    }
	    
	    @Override	    
	    public Integer existUser(String userid)
	    {
	    	try{
				return this.dao.existUser(userid);
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return null;
	         }  
	    }
	    
		@Override
		public boolean verifyUser(String userID, String pass) {
			// TODO Auto-generated method stub
			try{
				ModelUser modelUser = new ModelUser();
				modelUser.setUserID(userID);
				modelUser.setUserPass(pass);
				Integer flag = this.dao.verifyUser(modelUser);
				if (flag==1)
					return true;
				else  
					return false; 
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return false;
	         }  
		}
		
		@Override
		public ModelUser selectUser(String userID) {
			try{ 
				return this.dao.selectUser( userID );
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return null;
	         }  
		}

		@Override
		public Integer changePassWord(String userID, String pass) {
			// TODO Auto-generated method stub
			try{
				ModelUser modelUser = new ModelUser();
				modelUser.setUserID(userID);
				modelUser.setUserPass(pass);
				return  this.dao.changePass(modelUser);				
				 
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return null;
	         }  
		}

		
		@Override
		public Integer updateSessionId(ModelUser model) {
			try{
				return this.dao.updateSessionId(model);
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return null;
	         }  
		}

		@Override
		public String getSessionId(String userID) {
			try{
				return this.dao.getSessionId(userID);
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return null;
	         }  
		}
		
		
 
	    @Override
	    public List<ModelRole> selectRoles()
	    {
	    	try{ 
				return this.dao.selectRoles();
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return null;
	         }
	    }
	    
	    @Override
	    public Integer insertRole(ModelRole model)
	    {
	    	try{ 
	    		return this.dao.insertRole(model);
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return null;
	         }  
	    }

		@Override
		public Integer deleteRole(String roleID) {
			try{
				return this.dao.deleteRole(roleID);
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return null;
	         }  
		}

		@Override
		public Integer updateRole(ModelRole model) {
			try{
	    		return this.dao.updateRole(model);
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return null;
	         }  
		}

		@Override
		public Integer existRole(String roleID) {
			try{
				return this.dao.existRole(roleID);
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return null;
	         }  
		}

		@Override
		public List<ModelUserRole> selectUserRoles(String UserID) {
			try{
				return this.dao.selectUserRoles(UserID);
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return null;
	         }  
		}

		@Override
		public Integer deleteUserRoles(String UserID) {
			try{
				return this.dao.deleteUserRoles(UserID);
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return null;
	         }  
		}

		@Override
		public Integer insertUserRole(ModelUserRole model) {
			try{
				return this.dao.insertUserRole(model);
			 } catch (Exception e) {  
	             e.printStackTrace();  
	             return null;
	         }  
		}






}
